package com.lw.system.controller;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import com.lw.common.basemodel.Json;
import com.lw.common.core.service.BaseServiceI;
import com.lw.common.web.controller.BaseController;
import com.lw.system.model.Menu;
import com.lw.system.service.MenuService;

/**
 * 
* @Title: MenuController.java 
* @Package com.lw.controller 
* @Description: 菜单service
* @author 刘伟  15818570028@163.com   
* @date 2016年12月21日 下午6:57:25 
* @version V1.0
 */
@RestController
@RequestMapping("/menu")
public class MenuController extends BaseController<Menu, String>  {
	@Resource
	private MenuService menuService;

	@Override
	public BaseServiceI<Menu, String> getBaseService() {
		return menuService;
	}

	@RequestMapping(value = "/findAllTreeNode", method = RequestMethod.GET)
	public List<Menu> findAllTreeNode() {

		return menuService.findAllTreeNode();
	}

	@RequestMapping(value = "/treegrid", method = RequestMethod.GET)
	public  List<Menu>  treegrid() {
		return menuService.treegrid();
	}

	@RequestMapping(value = "/remove", method = RequestMethod.POST)
	public Json remove(String id) {
		return menuService.remove(id) > 0 ? setSimpleSuccess(id) : setFailed();
	}

	@RequestMapping(value = "/add", method = RequestMethod.POST)
	public Json add(Menu menu) {

		return menuService.add(menu) > 0 ? setSimpleSuccess(menu) : setFailed();
	}

	@RequestMapping(value = "/edit", method = RequestMethod.POST)
	public Json edit(Menu menu) {

		return menuService.edit(menu) > 0 ? setSimpleSuccess(menu) : setFailed();
	}

}
